#include "Check.h"
#include <iostream>
#include "Colour.cpp"
using namespace std;
int CheckResult(struct ScoreData* cek){
	auto int DataFlag=0;
	bool ScrCek[2]={false,false},PntCek=false;
	if(cek->Score >=scr[(int)SML].floor&&cek->Score<=scr[(int)SML].utmost){ScrCek[0]=true;}//5 Scale Check Pass
	if(cek->Score >=scr[(int)BIG].floor&&cek->Score<=scr[(int)BIG].utmost){ScrCek[1]=true;}//100 Scale Check Pass 
//Score Stardard-Input Validity Check
	if(ScrCek[0]==false&&ScrCek[1]==false){
		DataFlag+=0x01<<(int)SCRERR;	//Two Fail ==> DataFlag=1(0x01)
//		cek->DataPass=false;
	}else if(ScrCek[0]==false&&ScrCek[1]==true){
		DataFlag+=0x01<<(int)SCRWRN;	//NonStandard Score Input ==>DataFlag=2(0x02)
	}
//Point Input Validity Check
	if(cek->Point>=pnt.floor&&cek->Point<=pnt.utmost){
		PntCek=true;
	}
	DataFlag+=0x01<<((int)PntCek+2);		//PASS<=>+8,FAIL<=>+4 
//	if(PntCek==false){cek->DataPass=false;}
//Status Flag Note
//Flag=8 Normal; 
	return DataFlag;
}
void WerrorDisplay(int StatusCode,struct ScoreData* cek,int Line){
	cout<<"Data_Input "<<Line+1<<" --- "<<cek->SubjectName<<" ";
	if((StatusCode&0x0C)==0x04){			//Point_Input Invaild is detected.The Fault is Error display
		SetWerrColour(ERR);
		//cout<<cek->Point;
		printf("%.2f",cek->Point);	
		//C type output stream,not using the 
		SetColour((int)Default.FrontColour,(int)Default.BackColour); 
	}else if((StatusCode&0x0C)==0x08){	//Normal Condition
			printf("%.2f",cek->Point);
	}
	cout<<" ";
	if((StatusCode&0x03)==0x01){			//Two Score-Scale Test Fail
		SetWerrColour(ERR);
		cout<<cek->Score;
		SetColour((int)Default.FrontColour,(int)Default.BackColour);
		cout<<" ";
	}else if((StatusCode&0x03)==0x02){	//100 Scale Pass
		SetWerrColour(WRN);
		cout<<cek->Score;
		ScoreTransfer(cek);
		SetColour((int)Default.FrontColour,(int)Default.BackColour);
		//cout<<"("<<cek->Score<<") ";
		printf("(%.2f) ",cek->Score);
	}
//	cout<<cek->GPAOrNot;
	if(cek->Score<1.0){
	cout<<endl;
	SetColour((int)PUR,(int)YEL);
	cout<<"Subject FAIL,NEED MAKE-UP EXAM";}
	cout<<endl;
	SetWerrColour(DFT); 
	Sleep(500);		//Delay 500ms
	return;
}
void ScoreTransfer(struct ScoreData* cek){
	cek->Score-=Transfer_100To5_1;
	cek->Score/=Transfer_100To5_2;//100 Point Scale --> 5 Point Scale Transformation 
	return; 
}
void SetWerrColour(WERR Flag){
	if(Flag==WRN){
		SetColour((int)WarningSet.FrontColour,(int)WarningSet.BackColour);
	}else if(Flag==ERR){
		SetColour((int)ErrorSet.FrontColour,(int)ErrorSet.BackColour);
	}else{
		SetColour((int)Default.FrontColour,(int)Default.BackColour);
	}
	return;
}
